<?php
/* @var $this ProductController */

$this->breadcrumbs=array(
	'Product',
);
//判断是否是有活动
$promotion = CmpPromotion::model()->getPromotion($productinfo['zp_id']);
//评分
$avg = OrdComment::model()->getProAvg($productinfo['zp_id']);
//print_r($avg );
?>
<script type="text/javascript">
    $(document).ready(function() {       
        /*
         * 暴力清除商品浏览历史记录！
         */
        $("#clearRec").click(function (event) {
            $.ajax({
                url: "<?php echo Yii::app()->createUrl('/item/clearHistory') ?>",
                async: false
            }),
            $(".recent").html("").append("<div style='padding:20px'>没有商品浏览记录!</div>");
        });
        /*
         * 加入进货单 
         */
        $("#LinkPurchase").click(function (event) {
            /******判断规格********/
            var ids = '<?php echo isset($speids)?$speids:""?>';
            var flag = 0;
            var cc = '';
            var pronum = $("#pronum").val()|1;
            var inventory = $('#inventory').html();
            if(ids!='')
            {
               var id_arr = ids.split(',');
                for(var i=0;i<id_arr.length;i++){
                    var spec = $('#sel_color_ipt_'+id_arr[i]).val();
                    cc += spec+',';
                    if(spec=='')
                    {
                        flag = 1;
                    }
                }
            }                
            if( pronum > inventory ){                
                alert("库存不足!请修改您的下单数量!");
                return false;
            }
            if(flag==0)
            {

                <?php $n='0'; foreach ( (array)$productinfo['spe'] as $key=>$val ){  $n++?>
                var spe<?php echo $n?> = $("#sel_color_ipt_<?php echo $key ?>").val()
                <?php }?>
                $.ajax({
                    type:"POST",
                    url: "<?php echo Yii::app()->createUrl('/cart/addCart') ?>",
                    data:"id="+<?php echo empty($productinfo['zp_id'])?'0':$productinfo['zp_id'] ?>+"&qty="+pronum<?php echo isset($ajaxspe)?$ajaxspe:"" ?>,
                    success: function(msg){
                        if(msg==1){
                            alert("库存不足");
                        }else if(msg==2){
                            alert("库存为0");
                        }else{
                            alert("成功加入购物车");
                        }
                        
                    }
                })
            }else{
                alert("请选择商品的规格!");
            }
        });
        /*
         * 立即购买 
         */
        $("#Buynow").click(function (event) {
            /******判断规格********/
            var ids = '<?php echo isset($speids)?$speids:""?>';
            var flag = 0;
            var cc = '';
            var pronum = $("#pronum").val()|1;
            var inventory = $('#inventory').html();
            if(ids!='')
            {
               var id_arr = ids.split(',');
                for(var i=0;i<id_arr.length;i++){
                    var spec = $('#sel_color_ipt_'+id_arr[i]).val();
                    cc += spec+',';
                    if(spec=='')
                    {
                        flag = 1;
                    }
                }
            }            
            if( pronum > inventory ){                
                alert("库存不足!请修改您的下单数量!");
                return false;
            }
            if(flag==0)
            {
                return true;
            }else{
                alert("请选择商品的规格!");
                return false;
            }
        });

        
    });
</script>
<div class="w_960 o_a">
	<div class="col_sub w_190 f_l">
    	<!--宝贝分类start-->
        <div class="pro_classify">
        	<div class="hd bg"><h2 class="fs_14"><a class="c_white" href="javascript:">所有宝贝分类</a></h2></div>
            <div class="bd">
            	<ul id="proSort">
                    <?php foreach($category as $key=>$val){?>    
                        <?php if($val['zca_visible']==1){?>                
                        <li class="item <?php if(isset($productinfo['cattopid'])&&($productinfo['cattopid']==$val['zca_id'])){?> open<?php }?>">
                            <h3 class="c_green3 bg_x click"><?php echo $val['zca_title'] ?></h3>
                            <div class="list">
                                <ul class="li">
                                <?php if(isset($val['subcat'])){?>
                                <?php foreach($val['subcat'] as $k=>$v){?>
                                    <?php if($v['zca_visible']==1){?>  
                                        <li class="<?php if(isset($productinfo['catparentid'])&&($productinfo['catparentid']==$v['zca_id'])){?> open<?php }?>">
                                            <p class="h"><span class="ico ico_fold click2"></span><?php echo CHtml::link($v['zca_title'], array('/home/product/list', 'id' => $v['zca_id']), array('title' => $v['zca_title'],'class' => 'c_666 fw_b'))?><span class="c_999 d_n">（<?php echo $v['pro_count'] ?>）</span></p>
                                            <ul class="sub line_20">
                                            <?php if(isset($v['subcat'])){?>
                                              <?php foreach( (array)$v['subcat'] as $key3=>$val3){?>
                                                  <?php if($val3['zca_visible']==1){?>  
                                                    <li><?php echo CHtml::link($val3['zca_title'], array('/home/product/list', 'id' => $val3['zca_id']), array('title' => $val3['zca_title'],'class' => 'c_999'))?><span class="c_999 d_n">（<?php echo $val3['pro_count'] ?>）</span></li>
                                                  <?php }
                                                }
                                            }?>
                                            </ul>
                                        </li>
                                    <?php }
                                     }
                                }?>
                                </ul>
                            </div>
                        </li>     
                        <?php }?>               
                    <?php }?>
                </ul>
            </div>
        </div>
        <!--宝贝分类end-->
        <!--同类产品推荐 start-->
        <div class="like_pro c_f mt10 bg_fff list_hover">
        	<div class="hd bg_x"><span class="fs_14 fw_b">同类产品推荐</span></div>
            <div class="bd">
            	<ul>
                    <?php
                    if(!isset($editView)){ //预览模式不作数据查询
                    $sql = new CDbCriteria(array(
                                'condition' => 'zp_status = 2 AND zp_state = 2 AND zp_id != ' . $productinfo['zp_id'] . ' and zca_id =' . $productinfo['zca_id'],
                                'limit' => '5'
                            ));
                    $items = Product::model()->findAll($sql);
                    if ($items) {                        
                        foreach ($items as $i) {
                            ?>
                            <li class="item">
                                <div class="c_img c_img160"><?php echo CHtml::link( Tool::thumb( $i->zp_pic,160,160,$i->zp_name ),array('/home/product/detail/', 'id'=>$i->zp_id ),array('target'=>'_blank','title'=>$i->zp_name) ) ?></div>
                                <p class="price ff_yh"><strong class="c_orange fs_15">&yen;<?php echo $i->zp_price ?></strong></p>
                                <p class="title title_pro c_666"><?php echo $i->getTitle() ?></p>
                            </li>                                            
                            <?php
                        }                        
                    } else {
                        ?>
                        <p style="text-align:center">没有找到商品!</p>
                    <?php }} ?>                	
                </ul>
            </div>
        </div>
        <!--同类产品推荐 end-->
        <!--浏览记录 start-->
        <div class="pub_a view_history c_f mt10 bg_fff">
        	<div class="hd bg_x"><a class="f_r c_06c" href="javascript:" title="">清除</a><span class="fs_14 fw_b">浏览记录</span></div>
            <div class="bd">
            	<ul>
                    <?php 
                        //取浏览记录
                        $proids = MemHistory::model()->readBrowsingHistory();
                        if (!empty($proids)) {
	                        $criteria=new CDbCriteria;
	                        $criteria->addInCondition('zp_id',$proids);
	                        $items = Product::model()->findAll($criteria);                      
	                        foreach ($items as $i) {
                    ?>
                        <li class="c_f">
	                        <div class="c_img c_img50 f_l"><?php echo CHtml::link( Tool::thumb( $i->zp_pic,50,50,$i->zp_name ),array('/home/product/detail/', 'id'=>$i->zp_id ),array('target'=>'_blank','title'=>$i->zp_name) ) ?></div>
	                        <p class="title title_pro1"><?php echo $i->getTitle() ?></p>
	                        <p class="price ff_yh"><strong class="c_orange fs_14">&yen;<?php echo $i->zp_price ?></strong></p>
                    	</li>
                    <?php
                        }
                        
                    } else {
                        ?>
                        <p style="text-align:center">没有找到浏览记录!</p>
                    <?php } ?>  
                </ul>
            </div>
        </div>
        <!--浏览记录 end-->
        <!--产品详细广告 A1 54 start-->
        <?php $adzone = Adzone::model()->getData(54);
        foreach( (array)$adzone['ads'] as $key=>$value){?>
        <div class="adv mt10">
            <?php echo CHtml::link(CHtml::image($value['zds_file_url'],!empty($value['zdz_desc'])?$value['zdz_desc']:'A1',array('height'=>$adzone['zdz_height'],'width'=>$adzone['zdz_width']),$value['zds_url'],array('target'=>'_blank')))?>
        </div>
        <?php }?>        
        <!--产品详细广告 A1 54 end-->
    </div> 
    <div class="col_main w_760 f_r">
    	<div class="detail_info c_f">
				<h2 class="c_666 fs_14 line_32"><?php echo  mb_substr($productinfo['zp_name'],0,100)?></h2>
				<div class="img c_f" id="photoAlbum">
					<div id="superAlbum">
						<span class="img_mask" id="img_mask"></span>
                        <div class="c_img big_img"><a href="javascript:"><img src="<?php echo $productinfo['zp_pic'] ?>" data-superbig="<?php echo $productinfo['zp_pic'] ?>" id="bigPIC" alt="<?php echo  $productinfo['zp_name'] ?>" /></a></div>
					</div>
					<ul class="s_img_list album_list c_f" id="album_list">
                        <?php if(isset($productinfo['imgs'])){foreach ((array)$productinfo['imgs'] as $key=>$val) {?>
                               <li class="item<?php if($key=='0'){ echo ' select';}?>"><a href="<?php echo $val['zpg_url']?>" data-superbig="<?php echo $val['zpg_url']?>"><?php echo Tool::Thumb($val['zpg_url'],50,50,$productinfo['zp_name']) ?></a></li>
                        <?php }} ?>						
					</ul>
					<div class="share c_f">
                        <!-- Baidu Button BEGIN -->
                        <div id="bdshare" class="bdshare_t bds_tools get-codes-bdshare">
                            <a class="bds_tsina"></a>
                            <a class="bds_tqq"></a>
                            <span class="bds_more">更多</span>
                            <a class="shareCount"></a>
                        </div>
                    <script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=3904611" ></script>
                    <script type="text/javascript" id="bdshell_js"></script>
                    <script type="text/javascript">
                        document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + new Date().getHours();
                    </script>
                    <!-- Baidu Button END -->
                    <a href="javascript:" class="ico ico_fav f_l" onclick="addFav('<?php echo Yii::app()->user->getId();?>')">收藏该商品</a>
                    <!-- <a href="/member/index/reportone/productid/<?php //echo $productinfo['zp_id'];?>" class="ico ico_report f_l">举报</a> -->
                    </div>
				</div>
                
    				<div class="info">
                    <?php if($productinfo['zp_status']==2||isset($editView)) {?>
                    <?php if($productinfo['zp_state']==2) {?>
    				<?php echo CHtml::beginForm(array('/cart/addToCart'), 'POST', array('id' => 'orderForm')) ?>
    				<?php echo CHtml::hiddenField('proinfo[id]', $productinfo['zp_id']) ?>
                    <?php echo CHtml::hiddenField('proinfo[zm_id]', $productinfo['zm_id']) ?>
                    <?php echo CHtml::hiddenField('proinfo[sn]', $productinfo['zp_product_no']) ?>
                    <?php echo CHtml::hiddenField('proinfo[title]', $productinfo['zp_name']) ?>
                    <?php echo CHtml::hiddenField('proinfo[pic_url]', $productinfo['zp_pic']) ?>
                    <?php echo CHtml::hiddenField('proinfo[saleprice]', $productinfo['zp_price']) ?>
                    <?php if($promotion){ //有活动?>
                        <?php if($promotion['type']=='discount'){ //促销专区?>
                        <?php echo CHtml::hiddenField('proinfo[price]', number_format($productinfo['zp_price']*$promotion['model']->zpd_discount/10,2,'.','')) ?>
                        <?php }elseif($promotion['type']=='promotion'){ //限时抢购?>
                        <?php echo CHtml::hiddenField('proinfo[price]', $promotion['model']->zpt_price) ?>
                        <?php }elseif($promotion['type']=='tuan'){ //团购?>
                        <?php echo CHtml::hiddenField('proinfo[price]', $promotion['model']->zpt_price) ?>
                        <?php }?>                        
                    <?php }else{ //没活动?>
                        <?php echo CHtml::hiddenField('proinfo[price]', $productinfo['zp_price']) ?>
                    <?php }?>
                    <?php echo CHtml::hiddenField('proinfo[weight]', $productinfo['zp_weight']) ?>
                    <?php echo CHtml::hiddenField('proinfo[exp_status]', $productinfo['zp_exp_status']) ?>
                    <?php echo CHtml::hiddenField('proinfo[ze_id]', $productinfo['ze_id']) ?>
    					<ul>
    						<?php if($promotion){ //有活动?>
    							<li class="item c_f"><span class="a">价格</span><span class="b"><del class="c_666"><?php echo $productinfo['zp_price']?>元</del></span></li>
    							<?php if($promotion['type']=='discount'){ //促销专区?>
                        			<li class="item c_f"><span class="a">促销</span><span class="b cx"><em>折扣促销</em></span><span class="c"><em class="price"><?php echo number_format($productinfo['zp_price']*$promotion['model']->zpd_discount/10,2,'.','')?></em> 元</span></li>
                        		<?php }elseif($promotion['type']=='promotion'){ //限时抢购?>
                        			<li class="item c_f">
                        				<span class="a">促销</span><span class="b cx"><em>限时抢购</em></span><span class="c"><em class="price"><?php echo $promotion['model']->zpt_price?></em> 元</span>
                        				<span id="snapup_timer" class="c c_999"><em class="clock_txt"></em><em class="clock"></em></span>
                        			</li>
                        		<?php }elseif($promotion['type']=='tuan'){ //限时抢购?>
                        			<li class="item c_f"><span class="a">促销</span><span class="b cx"><em>团购</em></span><span class="c"><em class="price"><?php echo $promotion['model']->zpt_price?></em> 元</span></li>
                        		<?php }?>
    						<?php }else{ //没活动?>
    							<li class="item c_f"><span class="a">价格</span><span class="b"><em class="price"><?php echo $productinfo['zp_price']?></em> 元</span></li>
    						<?php }?>
    						<li class="item c_f"><span class="a">配送</span>

                                <?php if($productinfo['zp_exp_status']==1){?>
                                <span class="b">卖家包邮</span>
                                <?php }else{?>
                                <span class="b">送至</span>
    							<span class="c po">
    								<input class="select_city ico" id="change_city" type="button" value="深圳" />
    								<div class="change_city_inner" id="change_city_inner" style="display:none;">
    									<ul class="zxCity c_f" id="C_zxCity">
    										
    									</ul>
    									<ul class="province c_f" id="C_area">
    										
    									</ul>
    									<ul class="city c_f" id="C_city" style="display:none;">
    										
    									</ul>
    									<a href="javascript:" class="close">关闭</a>
    								</div>
    							</span>
    							<span class="d"><em>快递：10元</em><em>EMS：20元</em></span>
                                <?php }?>
    						</li>
                            <li class="item c_f"><span class="a">月销量</span><span class="b"><strong class="c_red2"><?php echo $productinfo['zp_sale_num'] ?></strong> 件</span></li>
    						<li class="item c_f"><span class="a">评价</span><span class="b"><b class="star star<?php echo $avg['avg_star'] ?>"></b></span><span class="c"><?php echo $avg['avg_unite'] ?>分 (<a href="javascript:" class="c_green3">已有<?php echo isset($productinfo['commenttotal'])?$productinfo['commenttotal']:"0"?>人评价</a>)</span></li>
    					</ul>
    					<div class="shopping">
    						<?php $n=0;
    						if($productinfo['spe']){
    							foreach ((array)$productinfo['spe'] as $key=>$val){ $n++;?>
    							<input type="hidden" name="proinfo[spe][]" id="sel_color_ipt_<?php echo $key?>" value="" />
    								<div class="lin c_f">
    									<p class="left color"><?php echo isset($val['za_title'])?$val['za_title']:""?>：</p>
                                        <?php if($val['zps_photo'] == 2) 
                                            {
                                                $class = 's_img_list s_img_list_small';
                                            }
                                            else{
                                                $class = 's_txt_list s_txt_list_small';
                                            }
                                        ?>
    									<ul class="<?php echo $class ?>" id="sel_color_<?php echo $key?>" data-property="<?php echo $n ?>">		
    									   <?php foreach($val['zpa_val'] as $key1=>$val1){?>			
    										<li data-value="<?php echo $val1['zpa_val']?>" class="item" id="show_id_<?php echo $val1['zpa_id']?>">
                                                <a href="javascript:" class="txt" onclick="sele_spec(this,<?php echo $key?>,<?php echo $val1['zpa_id']?>,'<?php echo $val1['zpa_val']?>')">
                                                
                                                <?php
                                                if($val1['zps_photo']==2){
                                                 if($val1['zpa_pic']!=null) 
                                                    {
                                                       echo Tool::thumb($val1['zpa_pic'],30,30); 
                                                    }
                                                    else
                                                    {
                                                        echo '<span>'.$val1['zpa_val'].'</span>';
                                                    }
                                                }else{
                                                    echo $val1['zpa_val'];
                                                }
                                                ?>
                                            </a></li>																 						
    									  <?php }?>
    									</ul>
    								</div>    															 
    						<?php }
                             }else{?>
                             <input type="hidden" name="proinfo[spe]"  value="" />
                             <?php }?>
    						<!--<a href="images/p/pro_zs_01.jpg" data-superbig="images/p/2010_4_12_19_26_0_7826.jpg">									
    									 <img src="images/p/pro_zs_x_01.jpg" alt="" /></a></li>	 -->
    						<div class="lin c_f">
    							<p class="left">数量：</p>
    							<p class="left c_666"><input id="pronum" type="text" data="<?php echo $productinfo['zp_inventory'] ?>" class="t_ipt num" name="proinfo[qty]" value="1"/> 件(库存<span id="inventory"><?php echo $productinfo['zp_inventory'] ?></span>件)</p>
    						</div>
                                <p class="fs_12"><?php
                                    //错误提示!
                                    if(hasFlash()){
                                    renderFlash();
                                    } ?>
                                </p>    						
    						    <p class="buy"><input class="btn btn_buy2" type="submit" id="Buynow" value="" <?php if(isset($editView)) echo "disabled='disabled'"?> /><input class="btn btn_add" type="botton" value="" id="LinkPurchase"/></p>
    						
    					</div>
                        <?php echo CHtml::endForm(); ?>
                    <?php }else{?>
    				</div>
                    
                    <div class="info">
    					<ul>
    						<li class="item c_f"><span class="a">价格</span><span class="b"><em class="price"><?php echo $productinfo['zp_price']?></em> 元</span></li>
    					</ul>
                        <p class="tip fs_14 fw_b">此宝贝已下架</p>
    					<div class="hot_sales">
                        	<p class="h c_999">当前热销产品</p>
                            <ul class="c_f">
                            <?php
                            if(!isset($editView)){//预览模式不作数据查询
                            $sql = new CDbCriteria(array(
                                        'condition' => 'zp_status = 2 AND zp_state = 2 AND zp_id != ' . $productinfo['zp_id'] . ' and zca_id =' . $productinfo['zca_id'],
                                        'limit' => '6'
                                    ));
                            $items = Product::model()->findAll($sql);
                            if ($items) {                               
                                foreach ($items as $i) {
                                    ?>
                                    <li>
                                        <div class="c_img c_img110"><?php echo $i->getThumb() ?></a></div>
                                        <p class="price fw_b ff_yh c_orange">&yen;<?php echo $i->zp_price ?></p>
                                        <p class="title_pro1 c_666"><?php echo $i->getTitle() ?></p>
                                    </li>                                    
                                    <?php
                                }
                                
                            } else {
                                ?>
                                <p style="text-align:center">没有找到同类其他商品!</p>
                            <?php }} ?>
                            </ul>
                        </div>
    				</div>
                    <?php }?>
                <?php }else{?>
                <div class="info d_n">
                    <ul>
                        <li class="item c_f"><span class="a">价格</span><span class="b"><em class="price"><?php echo $productinfo['zp_price']?></em> 元</span></li>
                    </ul>
                    <p class="tip fs_14 fw_b">此宝贝正在审核中</p>
                    <div class="hot_sales">
                        <p class="h c_999">当前热销产品</p>
                        <ul class="c_f">
                            <?php
                            if(!isset($editView)){//预览模式不作数据查询
                            $sql = new CDbCriteria(array(
                                        'condition' => 'zp_status = 2 AND zp_state = 2 AND zp_id != ' . $productinfo['zp_id'] . ' and zca_id =' . $productinfo['zca_id'],
                                        'limit' => '6'
                                    ));
                            $items = Product::model()->findAll($sql);
                            if ($items) {                               
                                foreach ($items as $i) {
                                    ?>
                                    <li>
                                        <div class="c_img c_img110"><?php echo $i->getThumb() ?></a></div>
                                        <p class="price fw_b ff_yh c_orange">&yen;<?php echo $i->zp_price ?></p>
                                        <p class="title_pro1 c_666"><?php echo $i->getTitle() ?></p>
                                    </li>                                    
                                    <?php
                                }
                                
                            } else {
                                ?>
                                <p style="text-align:center">没有找到同类其他商品!</p>
                            <?php }} ?>                            
                        </ul>
                    </div>
                </div>
                <?php }?>
			</div></div>
        <div class="hr_20"></div>
        <!-- 套餐搭配 star -->
        <?php $package = ProPackage::model()->getPackages($productinfo['zp_id']); ?>
        <?php if(!empty($package)){?>
        <div class="packages">
        	<div class="hd">套餐名称</div>
            <div class="bd">
            	<div class="match_bar c_f">
                	<span id="matchpre" class="ico"></span>
                    <ul class="match_tab" id="matchTab">
                    <?php $count = count($package)?>
                    <?php for($i=0;$i<$count;$i++){?>
                        <li <?php if($count==1) echo "class='active'" ?> ><?php echo ($i+1)?></li>
                    <?php } ?>
                    </ul>
                    <span id="matchnext" class="ico"></span>
                </div>
                <div class="match_box" id="matchBox">
                	<ul class="match_cont" id="matchContent">
                		<?php foreach($package as $pack){?>
                    	<li class="item c_f">
                        	<ul class="match_list f_l">
                        		<?php foreach($pack->products as $data){?>
                            	<li class="<?php if($data->zp_id == $productinfo['zp_id']) echo "main"?>">
                                	<div class="c_img c_img80"><?php echo CHtml::link(Tool::thumb($data->zp_pic,80,80,$data->zp_name),array('/home/product/detail','id'=>$data->zp_id),array('target'=>'_blank')) ?></div>
                                    <p class="title_pro1"><?php echo CHtml::link(mb_substr($data->zp_name,0,10,'utf8'),array('/home/product/detail','id'=>$data->zp_id),array('class'=>'c_06c','target'=>'_blank')) ?></p>
                                    <p class="t_c"><strong class="ff_yh c_red2">&yen;<?php echo $data->zp_price?></strong></p>
                                    <p class="t_c d_n"><del class="ff_yh c_999">&yen;32.00</del></p>	
                                </li>
                                <?php }?>
                            </ul>
                            <div class="match_info f_l">
                            	<p><span>套餐价：</span><strong class="fs_16 ff_yh c_red2">&yen;<?php echo $pack->zpp_price?></strong></p>
                                <p><span>节省：</span><del class="ff_yh">&yen;<?php echo ($pack->costPrice-$pack->zpp_price)?></del></p>
                                <p>购买套餐</a><?php echo CHtml::link('购买套餐',array('/home/package/index','id'=>$pack->zpp_id,'pid'=>$productinfo['zp_id']),array('class'=>'btn btn_match','target'=>'_blank'))?></p>
                            </div>
                        </li>
                        <?php }?>
                    </ul>
                </div>
            </div>
            <?php if($count>1){?>
            <script type="text/javascript">				
				new Marquee(
				{
				MSClass : ["matchBox","matchContent","matchTab","onclick"],
				PrevBtnID : "matchpre",
				NextBtnID : "matchnext",
				Direction : 2,
				Step : 0.5,
				Width : 740,
				Height : 162,
				Timer : 20,
				DelayTime : 5000,
				WaitTime : 8000,
				ScrollStep: 0,
				SwitchType: 0,
				AutoStart : true
				});
			</script>
			<?php }?>
			<!-- 套餐搭配 end -->
        </div>
        <div class="hr_15"></div>
        <?php }?>
        <div class="pro_detail" id="pro_detail">
        	<div class="tab_hd2">
            	<ul class="c_f">
                	<li><a href="javascript:" title="">商品详情<b class="bg_x left"></b><b class="bg_x right"></b></a></li>
                    <li><a href="javascript:" title="">累计评价（<strong><?php echo isset($comments)?$comments:"0"?></strong>）<b class="bg_x left"></b><b class="bg_x right"></b></a></li>
                    <li><a href="javascript:" title="">成交记录（<strong><?php echo isset($dataProvider)?$dataProvider->totalItemCount:"0"; //echo $productinfo['zp_sale_num']?></strong>）<b class="bg_x left"></b><b class="bg_x right"></b></a></li>
                    <li><a href="javascript:" title="">售后服务<b class="bg_x left"></b><b class="bg_x right"></b></a></li>
                </ul>
            </div>
            <!--商品详情 start-->
            <div class="tab_cont2 mt10">
            	<div class="pro_info bg_fff">
                	<ul class="c_f">
                        <?php if(isset($productinfo['att'])){ foreach ((array)$productinfo['att'] as $val) {?>
                        <li><?php echo $val['za_title'] ?>： <?php  echo is_array($val['zpa_val'])?join(' ',$val['zpa_val']):$val['zpa_val']; ?></li>
                        <?php }} ?>                    	
                    </ul>
                </div>
                <div class="detail mt10">
                	<div class="pub_hd hd">商品详情</div>
                    <div class="bd"><p class="t_c"><?php echo $productinfo['zp_content']?></p></div>
                </div>
            </div>
            <!--商品详情 end-->
            <!--累计评价 start-->
            <div class="tab_cont2 mt10">
            	<div class="pingjia" id="evaluate">
                    <div class="pub_hd hd">累计评价（<?php echo isset($productinfo['commenttotal'])?$productinfo['commenttotal']:"0"?>）</div>
                    <div class="bd">
                        <div class="score c_f">
                            <div class="left">宝贝与描述相符<em class="em"><?php echo $avg['avg_unite'] ?></em>分<span class="total">共<?php echo isset($productinfo['commenttotal'])?$productinfo['commenttotal']:""?>次打分</span></div>
                            <div class="star_node">
                                <ul>
                                    <li class="item"><b class="star star50"></b><span class="jd"><b class="x" style="width:<?php echo $avg['avg_describe']*10 ?>px;"></b></span><span class="num">80.00%</span></li>
                                    <li class="item"><b class="star star40"></b><span class="jd"><b class="x" style="width:10px;"></b></span><span class="num">10.00%</span></li>
                                    <li class="item"><b class="star star30"></b><span class="jd"><b class="x" style="width:10px;"></b></span><span class="num">10.00%</span></li>
                                    <li class="item"><b class="star star20"></b><span class="jd"><b class="x" style="width:0;"></b></span><span class="num">0.00%</span></li>
                                    <li class="item"><b class="star star10"></b><span class="jd"><b class="x" style="width:0;"></b></span><span class="num">0.00%</span></li>
                                </ul>
                            </div>
                        </div>
                        
                            <?php   
                            if(!isset($editView)){//预览模式取消此项                 
                                $this->renderPartial('_comments',array(
                                   'pid' => $productinfo['zp_id'],
                                  ));
							}
                            ?>   
                            <script type="text/javascript">                     
                               $('#listview .yiiPager a').live('click',function(){
                                       $.ajax({
                                           url:$(this).attr('href'),
                                           success:function(html){
                                               $('#listview').html(html);
                                           }
                                       });
                                       return false;//阻止a标签
                                   });
                            </script>
                    </div>
                </div>
            </div>
            <!--累计评价 end-->
            <!--月成交记录 start-->
            <div class="tab_cont2 mt10">
            	<div class="record">
                	<div class="pub_hd hd">成交记录（<?php echo isset($dataProvider->totalItemCount)?$dataProvider->totalItemCount:"";?>）</div>
                    <div class="bd">
                    	<table class="record_tab" width="100%" cellpadding="0" cellspacing="0">
                        	<tr>
                            	<th width="22%">买家</th>
                                <th width="25%">宝贝名称</th>
                                <th width="13%">拍下价格</th>
                                <th width="10%">购买数量</th>
                                <th width="20%">成交时间</th>
                                <th width="10%">状态</th>
                            </tr>
                        </table>
                        <?php 
                        if(!isset($editView)){//预览模式取消此项
	                         $this->widget('zii.widgets.CListView', array(
	                            'dataProvider'=>$dataProvider,
	                            'emptyText'=>'<div class="news_con">暂时没有数据</div>',
	                            'template'=>'{items}{pager}',
	                            'itemView'=>'_listitem',
	                            'itemsTagName'=>'table',
	                            'itemsOptions'=>array('class'=>'list_table list_table2','width'=>'100%','cellpadding'=>0,'cellspacing'=>0),
	                            'pager'=>array('class'=>'CLinksPager'),
	                            'buttonCssClass'=>'bg_x btn_page',
	                        ));
						}
						 ?>
                    </div>
                </div>
            </div>
            <!--月成交记录 end-->
            <div class="tab_cont2 mt10">售后服务</div>
        </div>
        <div class="hr_15"></div>
        <!--热销推荐 start-->
         <div class="pro_list list_hover">
            <div class="pub_hd">热销推荐</div>
            <div class="bd pro_list">
                <ul class="list c_f">
                    <?php	if(!isset($editView)){ //预览模式不作数据查询
                            $sql = new CDbCriteria(array(
                                        'condition' => 'zp_status = 2 AND zp_state = 2 AND zp_id != ' . $productinfo['zp_id'] . ' and zca_id =' . $productinfo['zca_id'],
                                        'limit' => '8'
                                    ));
                            $items = Product::model()->findAll($sql);
                            if ($items) {
                                $k = 0;                                
                                foreach ($items as $i) {
                                    $k++?>
                                    <li class="item<?php if( $k%4 == 0 ){echo ' no_mr';}?>">
                                        <div class="c_img c_img160"><?php echo CHtml::link( Tool::thumb( $i->zp_pic,160,160,$i->zp_name ),array('/home/product/detail/', 'id'=>$i->zp_id ),array('target'=>'_blank','title'=>$i->zp_name) ) ?></div>
                                        <p class="price ff_yh"><del class="c_999 f_r">&yen;<?php echo $i->zp_price ?></del><strong class="fs_15 c_orange">&yen;<?php echo $i->zp_price ?></strong></p>
                                        <p class="title c_666"><?php echo $i->getTitle() ?></p>
                                        <p class="buy"><?php echo CHtml::link('点击购买', array('/home/product/detail', 'id'=>$i->zp_id), array('class'=>'btn btn_buy'))?></p>
                                    </li>                                                                
                                    <?php
                                }
                                
                            } else {
                                ?>
                                <p style="text-align:center">没有找到同类热销商品!</p>
                            <?php } }?>
                    
                </ul>
            </div>
        </div>  
        <!--热销推荐 end--> 
    </div>
</div>
<div class="po_bigView" id="po_bigView"><img src="" class="superPIC" id="superPIC" alt="" /></div>
<script type="text/javascript" src="/js/city.js"></script>

<script src="/stats/page" charset="utf-8" type="text/javascript"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/snapup_timer.js"></script>
<script>

$(function(){
	new photoAlbum($('#photoAlbum'));/*相册*/
	new superIMG($('#superAlbum'));/*摸过去放大*/	
	$('#change_city').changeCity();/*选择城市*/	
	$("#proSort").Subsort();
	$("#proSort").Subsort2();	
	$(".list_hover").Prolist();
	$("#pro_detail").TabADS2();
	$('#evaluate').TabADS3();
	$('.c_img50 img').LoadImage(true,50,50);
	$('.c_img110 img').LoadImage(true,110,110);
	$('.c_img160 img').LoadImage(true,160,160);
	$('.big_img img').LoadImage(true,320,320);
	$(".list_page li").mousedown(function(){
	$(".list_page li ").removeClass("cur");
		$(this).addClass("cur");
	});
	//倒计时需要的全局变量
	window.shop_status = "1";//来源于服务器的抢购进行状态
	window.server_time = "<?php echo date('Y/m/d H:i:s')?>";//来源于服务器的当前时间
	window.stime = "<?php if($promotion&&$promotion['type']=='promotion') echo date('Y/m/d H:i:s',$promotion['model']->zpt_start_time)?>";//来源于服务器的开始时间
	window.ctime = "<?php if($promotion&&$promotion['type']=='promotion') echo date('Y/m/d H:i:s',$promotion['model']->zpt_end_time)?>";//来源于服务器的结束时间
	$('#snapup_timer').clockon();
});
//规格的选择
function sele_spec(obj,id,spid,va,type)
{
    
    var ids = '<?php echo isset($speids)?$speids:""?>';  
    var aa = $('#sel_color_ipt_'+id).val();
    var bigPIC = $('#bigPIC');
    var superPIC = $('#superPIC');
    var imgSRC='',superimgSRC='';
    if(aa==va)
    {
        $('#show_id_'+spid).removeClass("select");
        $('#sel_color_ipt_'+id).val('');
    }
    else
    {
        if(aa!=''){$('#sel_color_'+id).find('.item').removeClass("select");}
        $('#sel_color_ipt_'+id).val(va);
        $('#show_id_'+spid).addClass("select");                
        if(type==2)
        {
            var a = $(this).find('a')
            imgSRC = a.attr('href');
            superimgSRC = a.attr('data-superbig')
            bigPIC.attr('src',imgSRC);
            //超级大图
            superPIC.attr('src',superimgSRC);
        }else{
            
        }
    }      
    //当团购或抢购过期
    <?php if(!empty($promotion)) {?>
        return false;
    <?php }?>            
    //判断是不是所有的规格都已经选取,选取则
    var flag = 0;
    var cc = '';
    var id_arr = ids.split(',');
    if(ids!='')
    {
        for(var i=0;i<id_arr.length;i++){
            var spec = $('#sel_color_ipt_'+id_arr[i]).val();
            cc += spec+',';
            if(spec=='')
            {
                flag = 1;
            }
        }                
    }
    //alert(flag);
    if(flag==0)
    {
        var goods_id = $('#proinfo_id').val(); 
        $.ajax({
            type:"POST",
            url: "<?php echo Yii::app()->createUrl('/Ajax/SpePrice') ?>",
            data:"id="+goods_id+"&spe="+cc, 
            success: function(data){                
                json = eval("(" + data + ")");
                if(json.errors==1){
                    alert('数据出错!');
                }else{
                    if(json.speprice > 0 | json.speprice!=''){
                    $('#proinfo_price').val(json.speprice);
                    $('.info .price').html(json.speprice);
                    }
                    if(json.inventory > 0 | json.inventory!=''){
                        $('#inventory').html(json.inventory);
                    }else{
                        $('#inventory').html(0);
                    }
                    $('#proinfo_sn').val(json.goods_no);
                }                         
            }
        })
    }
}

//添加收藏
function addFav(userid){
    if (userid) {
        var form_data = {
            productid:<?php echo empty($productinfo['zp_id'])?"0":$productinfo['zp_id'];?>,
            ajax:'1'
        };
        $.ajax({
            url:"<?php echo Yii::app()->createUrl('/ajax/AjaxFavorites/') ?>",
            type:'POST',
            data:form_data,
            success:function(msg){
                alert(msg);
            }
        });  
    }
    else{
        window.location.href= '/home/user/login';
    }
        

};


</script>